package common

import (
	"common/checkImg"
	"common/models"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

// GetCheckImg 验证码图片
// @Summary 验证码图片
// @Description 获取验证码图片
// @Tags 通用
// @Produce application/json
// @Security ApiKeyAuth
// @Success 200 {object} docModel.DocResp
// @Router /common/checkImg [get]
func (h CHandler) GetCheckImg(c *gin.Context) {
	img := new(models.CheckImg)
	resp := new(models.RespData)
	searchId, b64s, err := checkImg.Generate("video", h.R)
	if err != nil {
		zap.L().Error("Common:GetCheckImg checkImg.Generate error", zap.Error(err))
		resp.SendCode(c, models.CodeServerBusy)
		return
	}
	img.SearchId = searchId
	img.B64s = b64s
	resp.Data = img
	resp.SendSuccess(c)
}
